package barney.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import barney.excepcion.DAOExcepcion;
import barney.negocio.SeguridadReparacion;

/**
 * Servlet implementation class RegistrarUsuario
 */
@WebServlet("/RegistrarReparacionServlet")
public class RegistrarReparacionServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public RegistrarReparacionServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String a = request.getParameter("objeto");
		String b = request.getParameter("descripcion");
		String c = request.getParameter("pabellon");
		String d = request.getParameter("ubicacion");
		String f = "1";
		
		//Llamamos a la clase NEGOCIO
		SeguridadReparacion neg = new SeguridadReparacion();
		
		try{
			neg.insertarReparacion(a, b, c, d, f);	
			RequestDispatcher rd = request.getRequestDispatcher("/reparacion_registrar.jsp");
			rd.forward(request, response);
		}catch(DAOExcepcion e){
			RequestDispatcher rd = request.getRequestDispatcher("error.jsp");	
			rd.forward(request, response);
		}
				
	}

}
